<template>
  <div>
    <div class="addfriend_wrap">
      <div class="imgwrap">
        <img :src="otherInfo.u_HeadPortrait"
             style="width:100px;height:100px"
             @click="photoVisible=true">
      </div>

      <div class="info">
        <div>账号:<span>{{otherInfo.u_LoginID}}</span></div>
        <div>昵称:<span>{{otherInfo.u_NickName}}</span></div>
        <div>姓名:<span>{{otherInfo.u_Name}}</span></div>
        <div>年龄:<span>{{otherInfo.u_Age}}</span></div>
        <div>性别:<span>{{otherInfo.u_Sex}}</span></div>
        <div>签名:<span>{{otherInfo.u_Signature}}</span></div>
        <div>生日:<span>{{otherInfo.u_Birthday}}</span></div>
        <div>邮箱:<span>{{otherInfo.u_Email}}</span></div>
        <div>电话:<span>{{otherInfo.u_Telephone}}</span></div>
        <div>介绍:<span>{{otherInfo.u_Intro}}</span></div>
      </div>
    </div>

    <!-- 预览图片弹窗 -->
    <el-dialog :visible.sync="photoVisible"
               width="40%"
               append-to-body>
      <span> <img :src="otherInfo.u_HeadPortrait"
             style="width:100%"></span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: 'UserInfo',
  props: ['account'],
  created () {
    this.search()
  },
  data () {
    return {
      // 是否预览照片
      photoVisible: false,
      // 别人的信息
      otherInfo: {}
    }
  },
  methods: {
    // 搜索好友
    search () {
      this.$http.get('userinfo', { params: { username: this.account } }).then((response) => {
        const res = response.data
        if (res.code !== 200) {
          return this.$message.error(res.msg)
        }
        this.otherInfo = res.data
        return this.$message.success(res.msg)
      })
    }
  }
}
</script>
<style lang="less" scoped>
.addfriend_wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  .imgwrap {
    position: relative;
    top: 50px;
  }
  .info {
    padding-left: 35px;
  }
}
</style>
